<?php
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.gxgyl.com All rights reserved.

// +----------------------------------------------------------------------
// | Author: Liuyu
// +----------------------------------------------------------------------
declare (strict_types=1);

namespace app\common\model\shiyao;

use cores\BaseModel;

/**
 * 申办方模型
 * Class User
 * @package app\common\model
 */
class Company extends BaseModel
{
    // 定义表名
    protected $name = 'shiyao_company';

    // 定义主键
    protected $pk = 'company_id';

    /**
     * 商家用户详情
     * @param $where
     * @param array $with
     * @return array|static|null
     */
    public static function detail($where, array $with = [])
    {
        return static::get($where, $with);
    }

    /**
     * 累积用户可用余额
     * @param int $userId
     * @param float $money
     * @return mixed
     */
    public static function setIncBalance(int $companyId, float $money) {
        return (new static )->setInc($companyId, 'money_total', $money);
    }

    /**
     * 消减用户可用余额
     * @param int $userId
     * @param float $money
     * @return mixed
     */
    public static function setDecBalance(int $companyId, float $money) {
        return (new static )->setDec([['company_id', '=', $companyId]], 'money_total', $money);
    }
}
